/*
 * CheckLogin
 * 
 * Version information
 * 
 * Apr 10, 2006
 * 
 * Copyright (c) AmSoft Systems, 2006
 */
package net.amsoft.iservice.management.webapp.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.amsoft.iservice.management.util.IBrokerConstants;
import net.amsoft.iservice.management.webapp.dataObject.LoginData;
import net.amsoft.iservice.util.IServiceConstants;
import net.amsoft.iservice.util.IServiceUtil;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * Action used to check if user is logged in or not, if it is then takes <BR>
 * him to his homepage otherwise ask the iname to login
 * 
 * @author mohit
 * 
 */
public class CheckLogin extends BaseAction {

    public ActionForward process(ActionMapping oMapping, ActionForm oForm,
            HttpServletRequest oRequest, HttpServletResponse oResponse)
            throws Exception {
        IServiceUtil.log(IServiceConstants.INFO, this, F_PROCESS + F_ENTRY);
        LoginData oLoginData = (LoginData) oRequest.getSession(false)
                .getAttribute(IBrokerConstants.SESSION_LOGIN_OBJ);

        if (oLoginData.isLoginStatus()) {
            IServiceUtil.log(IServiceConstants.INFO, this, F_PROCESS + 
                    "redirect to=" + IBrokerConstants.FWD_SUCCESS);
            return oMapping.findForward(IBrokerConstants.FWD_SUCCESS);
        } else {
            IServiceUtil.log(IServiceConstants.INFO, this, F_PROCESS + 
                    "redirect to=" + IBrokerConstants.FWD_INAME_PAGE);
            return oMapping.findForward(IBrokerConstants.FWD_INAME_PAGE);
        }
    }

}
